<?PHP
class swfunc {

// DICHIARAZIONE DI FUNZIONE MUTUAL FRIEND
function CountMutualFriends3 ($ioio,$luilui) {
		   $sQuery = "SELECT COUNT(*)
			FROM `Profiles` AS p
			INNER JOIN (SELECT IF( '$luilui' = f.`ID` , f.`Profile` , f.`ID` ) AS `ID` 
			FROM `sys_friend_list` AS `f` 
			WHERE 1 AND (f.`Profile` = '$luilui' OR f.`ID` = '$luilui') AND `Check` = 1) AS `f1` ON (`f1`.`ID` = `p`.`ID`) 
			INNER JOIN (SELECT IF( '$ioio' = f.`ID` , f.`Profile` , f.`ID` ) AS `ID` 
			FROM `sys_friend_list` AS `f` 
			WHERE 1 AND (f.`Profile` = '$ioio' OR f.`ID` = '$ioio') AND `Check` = 1) AS `f2` ON (`f2`.`ID` = `p`.`ID`) 
        ";
		return (int)db_value($sQuery);
	}

//fa replace di di un testo url aggiugendo tag html

function urlreplace($text) {
  $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
    '<a target=\'_blank\'  href="\\1">\\1</a>', $text);
  $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
    '\\1<a target=\'_blank\'  href="http://\\2">\\2</a>', $text);
  $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
    '<a target=\'_blank\'  href="mailto:\\1">\\1</a>', $text);
  $text = ereg_replace("www+[^<>[:space:]]+[[:alnum:]/].fan-club.it","<a target=\'_blank\'  href=\"\\0\">\\0</a>", $text);
  $text = ereg_replace("(^| )(www([.]?[a-zA-Z0-9_/-])*)", "\\1<a target=\'_blank\'  href=\"http://\\2\">\\2</a>", $text);
  return $text;
} 

//taglia le stringe superiori a x caratteri
function tagliaz($testo,$maxCaratteri) 
{
 $caratteri = strlen($testo);
 if($caratteri > $maxCaratteri) {return substr($testo, 0, $maxCaratteri)."...";} else {return $testo;}
}

// Tipo di nome utente
Function TipoUtente($tipouser,$usformat)
{
 $aInfomember=getProfileInfo($tipouser);
 if ($usformat==1) 
 {
    $realname=ucfirst($aInfomember['FirstName'])." ".ucfirst($aInfomember['LastName']);
 }
 elseif ($usformat==2) 
 { 
    $realname =  ucfirst($aInfomember['FirstName']);
 }
 return $realname;
}

//Calcola la data di inserimento di news e commenti

Function TempoPost($inputdata,$datadaconf,$offset)
{ 
$differenza=intval((time()-(strtotime ($inputdata)+$offset))/60);
  		if ($differenza<60)
  		{
   			switch ($differenza)
			{
			 case 0: $miadata=_t('_ibdw_spywall_now');
			 case 1: $miadata=_t('_ibdw_spywall_oneminute');
			 break;
			 default: $miadata=_t('_ibdw_spywall_plusminutefirst')."$differenza"._t('_ibdw_spywall_plusminutesecond'); 
			 break;
   			}
  		}
  		else
  		{
   		 $ore=intval($differenza/60);
   		 if ($ore>=1 && $ore<2) {$miadata=_t('_ibdw_spywall_onehour');}
   		 elseif ($ore>=2 && $ore<25) {$miadata=_t('_ibdw_spywall_plushourfirst').$ore._t('_ibdw_spywall_plushoursecond');}
   		 elseif ($differenza>=1440 && $differenza<1500) {$miadata=_t('_ibdw_spywall_today');}
   		 elseif ($differenza>=1500 && $differenza<2880) {$miadata=_t('_ibdw_spywall_yesterday');}
   		 else 
		 {
		  if ($inputdata==NULL)
		  {$miadata=_t('_ibdw_spywall_dateprev');}
		  else {$miadata=_t('_ibdw_spywall_otherday').date($datadaconf, strtotime ($inputdata));}
		 }
  		}
  		$miadata='<span>'.$miadata.'</span>';
		return $miadata;
}

//FINE CLASSE
}
   function criptcodex($numero) 
   {
    $id0 = rand(1,9);
    $id1 = rand(10000,99999);    
    $mx = $numero*$id0;
    $generacriptcodex = $id0.$id1.$mx;
    return ($generacriptcodex); 
   }
    
   function decriptcodex($code) 
   {
    $estrazione0 = substr($code,0,1); 
    $estrazione = substr($code,6);   
    $mxestrazione = $estrazione/$estrazione0; 
    return ($mxestrazione); 
   }
?>






